home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / BKISSSRC.ZIP / LOADER / LOADER.ASM < prev    next >
Encoding:
Assembly Source File  |  1994-02-13  |  18.6 KB  |  490 lines

  1. ideal
  2. locals
  3. jumps
  4. p386
  5. model huge
  6. stack 100h
  7.  
  8.  
  9. segment     MyCode
  10.             assume cs:MyCode
  11. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  12. struc       DemoEXEname
  13. Exename     db 13 dup(0)
  14. ends        DemoEXEname
  15. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  16. macro       HandleError errormessage
  17.             local @@Label
  18.             jnc @@Label
  19.             mov [ErrorFlag],offset errormessage
  20.             jmp AllDone
  21. @@Label:    exitm
  22. endm        HandleError
  23. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  24. include     "XDETECT.ASM"
  25. include     "MENUS.INC"
  26. include     "PALETTE.INC"
  27. include     "EXECUTE.INC"
  28. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  29. extrn       LoaderFont:byte
  30. extrn       Farewell:byte
  31. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  32. include     "MUSGUS.INC"
  33. include     "MUSGUS.ASM"
  34. include     "MODLOAD.ASM"
  35. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  36. NormalAttr  = 1*16+15
  37. HighAttr    = 0*16+15
  38. ErrorFlag   DW 0        ;set to offset of error message and jump to AllDone
  39. ErrorNoVGA  DB 'This demo requires a system with a VGA card installed.',0Dh,0Ah,'$'
  40. ErrorNo386  DB 'This demo requires a system with at least a 386SX processor.',0Dh,0Ah,'$'
  41. ErrorEXE    DB 'Error executing part of demo.',0Dh,0Ah,'$'
  42. ErrorMOD    DB 'Error loading the music file.',0Dh,0Ah,'$'
  43. ErrorMusic  DB 'Error initializing music system.',0Dh,0Ah,'$'
  44. ExeNames    DemoEXEname <'SLIDETXT.EXE'>
  45.             DemoEXEname <'TITLE.EXE'>
  46.             DemoEXEname <'BOUNCE.EXE'>
  47.             DemoEXEname <'CANCEL.EXE'>
  48.             DemoEXEname <'STRETCH.EXE'>
  49.             DemoEXEname <'IRIS.EXE'>
  50.             DemoEXEname <'SINUS.EXE'>
  51.             DemoEXEname <'TUNNEL.EXE'>
  52.             DemoEXEname <'CREDITS.EXE'>
  53.             db 0
  54. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  55. PROC        Start
  56.             ;mov     bx,ss                   ; Shrink Program Segment
  57.             ;mov     ax,es
  58.             ;sub     bx,ax
  59.             ;mov     ax,sp
  60.             ;shr     ax,4
  61.             ;inc     ax
  62.             ;add     bx,ax
  63.             mov bx,64000/16
  64.             mov     ah,4Ah
  65.             int 21h
  66.             mov ax,MyCode                   ;\ set DS to CS
  67.             mov ds,ax                       ;/
  68.             call _x_graphics_card           ;\
  69.             cmp ax,VGAMono                  ; > check for VGA
  70.             HandleError ErrorNoVGA          ;/
  71.             call _x_processor               ;\
  72.             cmp ax,i386sx                   ; > check for 386
  73.             HandleError ErrorNo386          ;/
  74.             call fade_out                   ;fade out the display
  75.             mov ax,0003h                    ;\ change to text mode
  76.             int 10h                         ;/
  77.             mov ax,1100h                    ;\
  78.             mov bx,1000h                    ; \
  79.             mov cx,256                      ;  \
  80.             mov dx,0                        ;   \ load in our special font
  81.             mov bp,cs                       ;   /
  82.             mov es,bp                       ;  /
  83.             mov bp,offset LoaderFont        ; /
  84.             int 10h                         ;/
  85.             mov ah,01h                      ;\
  86.             mov cx,2607h                    ; > turn off the cursor
  87.             int 10h                         ;/
  88.             call GetVideoSegment            ;set ES to the video segment
  89.             mov di,0                        ;\
  90.             mov al,'░'                      ; \
  91.             mov ah,2*16+10                  ;  \ display a block background
  92.             cld                             ;  /
  93.             mov cx,80*25                    ; /
  94.             rep stosw                       ;/
  95.             mov si,offset MessageMsg        ;\
  96.             mov al,3*16+11                  ; \ display our message
  97.             mov ah,3*16+15                  ; /
  98.             call DisplayMenu                ;/
  99.             
  100.             ;*** Prompt user for output device ***
  101.             mov si,offset Soundcard
  102.             mov al,NormalAttr
  103.             mov ah,HighAttr
  104.             call HandleMenu
  105.             cmp bx,-1
  106.             jz AllDone
  107.             mov [_Soundcard],bx
  108.             shl bx,1
  109.             jmp [word Soundcards+bx]
  110. ENDP        Start
  111. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  112. PROC        SB_only
  113.             ;*** Prompt user for Sound Blaster port ***
  114.             mov si,offset SB_port
  115.             mov al,NormalAttr
  116.             mov ah,HighAttr
  117.             call HandleMenu
  118.             cmp bx,-1
  119.             jz AllDone
  120.             shl bx,1
  121.             mov ax,[SB_ports+bx]
  122.             mov [_SB_port],ax
  123.  
  124.             ;*** Prompt user for Sound Blaster IRQ number ***
  125.             mov si,offset SB_IRQ
  126.             mov al,NormalAttr
  127.             mov ah,HighAttr
  128.             call HandleMenu
  129.             cmp bx,-1
  130.             jz AllDone
  131.             shl bx,1
  132.             mov ax,[SB_IRQs+bx]
  133.             mov [_SB_IRQ],ax
  134.  
  135.             ;*** Prompt user for Mixing rate ***
  136. Non_GUS:    mov si,offset Replay_Rate
  137.             mov al,NormalAttr
  138.             mov ah,HighAttr
  139.             call HandleMenu
  140.             cmp bx,-1
  141.             jz AllDone
  142.             shl bx,1
  143.             mov ax,[Replay_Rates+bx]
  144.             mov [_Replay_Rate],ax
  145.  
  146.             ;*** Fade out the setup screen ***
  147.             call fade_out
  148.  
  149.             ;*** Initialize the correct sound device ***
  150.             mov ax,seg SOUNDDEVICE
  151.             mov es,ax
  152.             mov ax,[_Soundcard]         ;\
  153.             dec ax                      ; > set the playback device
  154.             mov [es:SOUNDDEVICE],ax     ;/
  155.             mov ax,[_Replay_Rate]       ;\ set the mixing speed
  156.             mov [es:TIMERSPEED],ax      ;/
  157.             ;mov ax,[_SB_DMA]           ;\ set the DMA
  158.             ;mov [es:SBDMA],ax          ;/
  159.             mov ax,[_SB_IRQ]            ;\ set IRQ number
  160.             mov [es:SBIRQNR],ax         ;/
  161.             mov ax,[_SB_port]           ;\ set the baseport
  162.             mov [es:SBPORT],ax          ;/
  163.             mov [es:MASTERVOLUME],64    ;set the initial volume
  164.             call INITIALIZE
  165.             mov dx,offset ModName       ;\
  166.             call LOADMODULE             ; > load in the module
  167.             HandleError ErrorMOD        ;/
  168.             call STARTPLAYING
  169.  
  170.             ;*** Run the demo ***
  171.             call DoDemo
  172.  
  173.             ;*** Deinitialize ourself ***
  174.             push ds
  175.             mov ax,seg SOUNDDEVICE
  176.             mov es,ax
  177. @@DecVol:   WaitForRetrace
  178.             WaitForRetrace
  179.             cmp [es:MASTERVOLUME],0
  180.             jz @@DecVol2
  181.             dec [es:MASTERVOLUME]
  182.             jmp @@DecVol
  183. @@DecVol2:  call STOPPLAYING
  184.             call DEALLOC
  185.  
  186.             ;*** Quit ***
  187.             jmp AllDone
  188. ENDP        SB_only
  189. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  190. PROC        GUS_only
  191.             ;*** Prompt user for Ultrasound port ***
  192.             mov si,offset GUS_port
  193.             mov al,NormalAttr
  194.             mov ah,HighAttr
  195.             call HandleMenu
  196.             cmp bx,-1
  197.             jz AllDone
  198.             shl bx,1
  199.             mov ax,[GUS_ports+bx]
  200.             mov [_GUS_port],ax
  201.  
  202.             ;*** Prompt user for IRQ number ***
  203.             mov si,offset GUS_IRQ
  204.             mov al,NormalAttr
  205.             mov ah,HighAttr
  206.             call HandleMenu
  207.             cmp bx,-1
  208.             jz AllDone
  209.             shl bx,1
  210.             mov ax,[GUS_IRQs+bx]
  211.             mov [_GUS_IRQ],ax
  212.  
  213.             ;*** Prompt user for MIDI IRQ number ***
  214.             mov si,offset GUS_MIDI
  215.             mov al,NormalAttr
  216.             mov ah,HighAttr
  217.             call HandleMenu
  218.             cmp bx,-1
  219.             jz AllDone
  220.             shl bx,1
  221.             mov ax,[GUS_MIDIs+bx]
  222.             mov [_GUS_MIDI],ax
  223.  
  224.             ;*** Prompt user for DMA in ***
  225.             mov si,offset GUS_DMAin
  226.             mov al,NormalAttr
  227.             mov ah,HighAttr
  228.             call HandleMenu
  229.             cmp bx,-1
  230.             jz AllDone
  231.             shl bx,1
  232.             mov ax,[GUS_DMAins+bx]
  233.             mov [_GUS_DMAin],ax
  234.             
  235.             ;*** Prompt user for DMA out ***
  236.             mov si,offset GUS_DMAout
  237.             mov al,NormalAttr
  238.             mov ah,HighAttr
  239.             call HandleMenu
  240.             cmp bx,-1
  241.             jz AllDone
  242.             shl bx,1
  243.             mov ax,[GUS_DMAouts+bx]
  244.             mov [_GUS_DMAout],ax
  245.             
  246.             ;*** Fade out the setup screen ***
  247.             call fade_out
  248.  
  249.             ;*** Initialize ourself ***
  250.             ;load in the MUSGUS driver
  251.             call MUS_LoadSoundDriver
  252.             HandleError ErrorMusic
  253.  
  254.             ;initialize the driver with the GUS settings
  255.             mov ax,[_GUS_IRQ]
  256.             mov cx,[_GUS_MIDI]
  257.             mov dx,[_GUS_port]
  258.             mov si,[_GUS_DMAin]
  259.             mov di,[_GUS_DMAout]
  260.             mov bx,0
  261.             call [dword ptr Music]
  262.             HandleError ErrorMusic
  263.  
  264.             ;set the initial volume
  265.             call MUS_GetInfo
  266.             mov [byte offset MMus+offset (SMus).MaxVolume],128
  267.             call MUS_SetInfo
  268.  
  269.             ;load in the module
  270.             mov ax,cs
  271.             mov ds,ax
  272.             mov dx,offset ModName
  273.             call MUS_LoadModule
  274.             HandleError ErrorMOD
  275.  
  276.             ;start playback
  277.             mov ax,[word MusBuf+0]
  278.             mov [Word offset PM_struc+0+offset (PM).MusBuf],ax
  279.             mov ax,[word MusBuf+2]
  280.             mov [Word offset PM_struc+2+offset (PM).MusBuf],ax
  281.             mov [Word offset PM_struc+0+offset (PM).Header],offset PS16Header
  282.             mov [Word offset PM_struc+2+offset (PM).Header],cs
  283.             mov [Word offset PM_struc+0+offset (PM).PatternLoc],offset PatternLoc
  284.             mov [Word offset PM_struc+2+offset (PM).PatternLoc],cs
  285.             mov [Word offset PM_struc+0+offset (PM).InsLoc],offset InsLoc
  286.             mov [Word offset PM_struc+2+offset (PM).InsLoc],cs
  287.             mov [Word offset PM_struc+offset (PM).mt_speed],6
  288.             mov [Word offset PM_struc+offset (PM).mt_counter],5
  289.             mov [Word offset PM_struc+offset (PM).mt_PatternPos],0
  290.             mov [Word offset PM_struc+offset (PM).mt_SongPos],0
  291.             mov cx,cs
  292.             mov si,offset PM_struc
  293.             mov bx,4
  294.             call [dword Music]
  295.  
  296.             ;*** Run the demo ***
  297.             call DoDemo
  298.  
  299.             ;*** Deinitialize ourself ***
  300.             mov ax,[word Music+0]
  301.             or ax,[word Music+2]
  302.             jz @@DontFade
  303. @@DecVol:   call MUS_GetInfo
  304.             dec [Byte offset MMus+offset (SMus).MaxVolume]
  305.             call MUS_SetInfo
  306.             WaitForRetrace
  307.             cmp [Byte offset MMus+offset (SMus).MaxVolume],0
  308.             ja @@DecVol
  309.  
  310. @@DontFade: call MUS_FreeModule
  311.             call MUS_FreeSoundDriver
  312.  
  313.             ;*** Quit ***
  314.             jmp AllDone
  315. ENDP        GUS_only
  316. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  317. PROC        No_Music
  318.             ;*** Fade out the setup screen ***
  319.             call fade_out
  320.  
  321.             ;*** Run the demo ***
  322.             call DoDemo
  323.  
  324.             ;*** Quit ***
  325.             jmp AllDone
  326. ENDP        No_Music
  327. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  328. PROC        DoDemo
  329.             mov [@@Filename],offset ExeNames
  330. @@ExeLoop:  mov ax,0C00h                    ;\ clear the keyboard buffer
  331.             int 21h                         ;/
  332.             mov ax,cs                       ;\
  333.             mov ds,ax                       ; \ execute the section
  334.             mov dx,[@@Filename]             ; /
  335.             call ExecuteProgram             ;/
  336.             mov [ErrorFlag],offset ErrorEXE
  337.             jc @@Quit
  338.             add [@@Filename],size DemoEXEname
  339.             mov si,[@@Filename]
  340.             cmp [byte si],0
  341.             jnz @@ExeLoop
  342.             mov [ErrorFlag],0
  343.             mov ax,0003h                    ;\ change back to text mode
  344.             int 10h                         ;/
  345.             mov ah,01h                      ;\
  346.             mov cx,2607h                    ; > turn off the cursor
  347.             int 10h                         ;/
  348. @@Quit:     ret
  349. @@Filename  dw ?
  350. ENDP        DoDemo
  351. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  352. PROC        AllDone
  353.             mov ax,0003h                    ;\ change back to text mode
  354.             int 10h                         ;/
  355.             call GetVideoSegment            ;set ES to the video segment
  356.             mov ax,cs                       ;\
  357.             mov ds,ax                       ; \
  358.             mov si,offset Farewell          ;  \
  359.             xor di,di                       ;   > display our leaving message
  360.             mov cx,4000                     ;  /
  361.             cld                             ; /
  362.             rep movsb                       ;/
  363.             mov ah,2                        ;\
  364.             xor bh,bh                       ; \
  365.             mov dh,22                       ;  > position the cursor
  366.             xor dl,dl                       ; /
  367.             int 10h                         ;/
  368.             cmp [ErrorFlag],0               ;\
  369.             jz @@Quit                       ; \
  370.             mov ah,9                        ;  \
  371.             mov dx,cs                       ;   > display an error message
  372.             mov ds,dx                       ;  / (if needed)
  373.             mov dx,[ErrorFlag]              ; /
  374.             int 21h                         ;/
  375. @@Quit:     mov ax,4C00h                    ;\ terminate program
  376.             int 21h                         ;/
  377. ENDP        AllDone
  378. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  379. ;related to playing the music
  380. ModName     db 'NEVER.MOD',0
  381. _Soundcard  dw ?
  382. _SB_port    dw 220h
  383. _SB_IRQ     dw 7
  384. _SB_DMA     dw 1
  385. _Replay_Rate dw ?
  386. _GUS_port   dw ?
  387. _GUS_IRQ    dw ?
  388. _GUS_MIDI   dw ?
  389. _GUS_DMAin  dw ?
  390. _GUS_DMAout dw ?
  391. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  392. ;related to the sound output selection menus
  393. MessageMsg  SelectorType <18,45,3,0>
  394.             DefineTitle 30,""
  395.             CenterString 30,"Bytes & Kisses"
  396.             CenterString 30,"Version 1.0"
  397.             CenterString 30,""
  398. Soundcard   SelectorType <5,5,10,0>
  399.             DefineTitle 30,"Sound Output Device"
  400.             CenterString 30,"No digital output  (Nothing)"," "
  401.             CenterString 30,"Gravis Ultrasound   (Stereo)"," "
  402.             CenterString 30,"Mono DAC on LPT1      (Mono)"," "
  403.             CenterString 30,"Mono DAC on LPT2      (Mono)"," "
  404.             CenterString 30,"Sound Blaster         (Mono)"," "
  405.             CenterString 30,"Internal speaker      (Mono)"," "
  406.             CenterString 30,"DAC on LPT1+LPT2    (Stereo)"," "
  407.             CenterString 30,"Sound Blaster Pro   (Stereo)"," "
  408.             CenterString 30,"Stereo DAC on LPT1  (Stereo)"," "
  409.             CenterString 30,"Stereo DAC on LPT2  (Stereo)"," "
  410. Soundcards  dw No_Music,GUS_only,Non_GUS,Non_GUS,SB_only,Non_GUS,Non_GUS
  411.             dw SB_only,Non_GUS,Non_GUS
  412. SB_port     SelectorType <3,35,7,1>
  413.             DefineTitle 25,"Sound Blaster Port"
  414.             CenterString 25,"210h"," "
  415.             CenterString 25,"220h"," "
  416.             CenterString 25,"230h"," "
  417.             CenterString 25,"240h"," "
  418.             CenterString 25,"250h"," "
  419.             CenterString 25,"260h"," "
  420.             CenterString 25,"270h"," "
  421. SB_ports    dw 210h,220h,230h,240h,250h,260h,270h
  422. SB_IRQ      SelectorType <14,25,2,1>
  423.             DefineTitle 25,"Sound Blaster IRQ"
  424.             CenterString 25,"IRQ 5"," "
  425.             CenterString 25,"IRQ 7"," "
  426. SB_IRQs     dw 5,7
  427. Replay_Rate SelectorType <7,45,11,0>
  428.             DefineTitle 30,"Select Replay Rate"
  429.             CenterString 30," 4000 Hz     (real slow)"," "
  430.             CenterString 30," 8000 Hz           (286)"," "
  431.             CenterString 30,"12000 Hz           (286)"," "
  432.             CenterString 30,"16000 Hz      (some 286)"," "
  433.             CenterString 30,"20000 Hz      (some 286)"," "
  434.             CenterString 30,"24000 Hz      (some 286)"," "
  435.             CenterString 30,"28000 Hz           (386)"," "
  436.             CenterString 30,"32000 Hz           (386)"," "
  437.             CenterString 30,"36000 Hz      (some 386)"," "
  438.             CenterString 30,"44100 Hz      (some 386)"," "
  439.             CenterString 30,"62799 Hz  (some 386/486)"," "
  440. Replay_Rates dw 298,149,99,74,60,50,43,37,33,27,19
  441. GUS_port    SelectorType <3,40,6,1>
  442.             DefineTitle 25,"Ultrasound Port"
  443.             CenterString 25,"210h"," "
  444.             CenterString 25,"220h"," "
  445.             CenterString 25,"230h"," "
  446.             CenterString 25,"240h"," "
  447.             CenterString 25,"250h"," "
  448.             CenterString 25,"260h"," "
  449. GUS_ports   dw 210h,220h,230h,240h,250h,260h
  450. GUS_IRQ     SelectorType <10,17,7,4>
  451.             DefineTitle 25,"Ultrasound IRQ"
  452.             CenterString 25,"IRQ 2"," "
  453.             CenterString 25,"IRQ 3"," "
  454.             CenterString 25,"IRQ 5"," "
  455.             CenterString 25,"IRQ 7"," "
  456.             CenterString 25,"IRQ 11"," "
  457.             CenterString 25,"IRQ 12"," "
  458.             CenterString 25,"IRQ 15"," "
  459. GUS_IRQs    dw 2,3,5,7,11,12,15
  460. GUS_MIDI    SelectorType <14,35,7,3>
  461.             DefineTitle 30,"Ultrasound MIDI IRQ"
  462.             CenterString 30,"IRQ 2"," "
  463.             CenterString 30,"IRQ 3"," "
  464.             CenterString 30,"IRQ 5"," "
  465.             CenterString 30,"IRQ 7"," "
  466.             CenterString 30,"IRQ 11"," "
  467.             CenterString 30,"IRQ 12"," "
  468.             CenterString 30,"IRQ 15"," "
  469. GUS_MIDIs   dw 2,3,5,7,11,12,15
  470. GUS_DMAin   SelectorType <10,45,5,4>
  471.             DefineTitle 30,"Ultrasound DMA in"
  472.             CenterString 30,"DMA 1"," "
  473.             CenterString 30,"DMA 3"," "
  474.             CenterString 30,"DMA 5"," "
  475.             CenterString 30,"DMA 6"," "
  476.             CenterString 30,"DMA 7"," "
  477. GUS_DMAins  dw 1,3,5,6,7
  478. GUS_DMAout  SelectorType <15,15,5,4>
  479.             DefineTitle 30,"Ultrasound DMA out"
  480.             CenterString 30,"DMA 1"," "
  481.             CenterString 30,"DMA 3"," "
  482.             CenterString 30,"DMA 5"," "
  483.             CenterString 30,"DMA 6"," "
  484.             CenterString 30,"DMA 7"," "
  485. GUS_DMAouts dw 1,3,5,6,7
  486. ;░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░
  487. ends        MyCode
  488. include     "GOLDPLAY.INC"
  489.             end Start
  490.